<template>
  <div class="pageComent">
    <div class="comment">
      <div class="c1">
        <div class="f1">
          <img v-if="comment.aut_photo" :src="comment.aut_photo" alt="" />
          <img v-else src="@/assets/logo.png" alt="" />
        </div>
        <div class="f2">
          {{ comment.aut_name }}
        </div>
        <div class="f3">
          <van-icon name="good-job-o" />
          <span>{{ comment.like_count }}</span>
        </div>
      </div>
      <div class="c2">
        <div class="title">
          {{ comment.content }}
        </div>
      </div>
      <div class="c3" v-if="bol">
        <div class="time">{{ comment.pubdate | filterTime }}</div>
        <div class="comments">
          <van-button round color="#f4f5f6" @click="reply(comment.com_id.c[1])"
            >{{ comment.reply_count }}回复</van-button
          >
        </div>
      </div>
      <div class="c3" v-else>
        <span v-if="total_count <= 0">没有更多了</span>
        <span v-else>姓名:某某某</span>
      </div>
    </div>
  </div>
</template>

<script>
// 引入封装评论
import { appComments } from '@/api/page.js'
export default {
  props: {
    comment: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  data () {
    return {
      total_count: '', // 回复总数
      bol: true // 回复开关
    }
  },
  methods: {
    // 点击回复
    async reply (id) {
      // 隐藏
      this.bol = false
      const res = await appComments({ type: 'c', source: id })
      console.log('----', res)
      this.total_count = res.total_count
    }
  }
  // async created () {
  //   // 添加评论
  //   const res = await appComments()
  //   console.log('---', res)
  // }
}
</script>

<style lang="less" scoped>
.pageComent {
  .comment {
    font-family: MicrosoftYaHei;
    font-size: 14px;
    font-weight: 400;
    font-stretch: normal;
    letter-spacing: 1px;
    color: #222222;
    .c1 {
      display: flex;
      align-items: center;
      justify-content: space-between;
      .f1 {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        img {
          width: 100%;
          height: 100%;
          border-radius: 50%;
        }
      }
      .f2 {
        color: #6885ae;
        padding-left: 10px;
        flex: 1;
      }
    }
    .c2 {
      white-space: pre-wrap;
      word-wrap: break-word;
      margin-top: 10px;
      padding-left: 36px;
      color: #494949;
    }
    .c3 {
      padding-left: 36px;
      margin-top: 10px;
      display: flex;
      align-items: center;
      justify-content: left;
      color: #494949;
      .van-button {
        margin-left: 15px;
        height: 30px;
      }
      ::v-deep .van-button__text {
        color: #494949;
      }
    }
  }
}
</style>
